#ifndef MPHTTPCONNECTIONMANAGETESTS_H
#define MPHTTPCONNECTIONMANAGETESTS_H

#include <QObject>
#include <QString>
#include <QtTest>

#include "Mapper/mpHttpConnectionManageThread.h"
#include "mpTestConfig.h"

//#define MP_JUST_MULTITHREAD


class mpHttpConnectionManageTests : public QObject
{
    Q_OBJECT

public:
    mpHttpConnectionManageTests();

private Q_SLOTS:

    void initTestCase();
    void cleanupTestCase();

#ifndef MP_JUST_MULTITHREAD
    //获取Http连接，优先从POOL缓存池中获取，如没有则自动创建
    void getHttpConnectionNewCase();
    void getHttpConnectionFromPoolCase();
    void getHttpConnectionFromPoolCase2();
    //缓存HTTP连接且缓存具有有效期[受max_cache_seconds约束，默认20秒]
    void getHttpConnectionFromPoolExpireCase();
    //限制Http连接管理器中活动的Http连接数量，超过上限时将无法在获取HTTP连接[受max_count_allocations约束，默认10个]
    void getHttpConnectionMaxCountCase();
    //限制Http连接管理器同一域名缓存的Http连接数量，超过上限时将会自动移除缓存中最早的一个连接[受max_count_preKey约束，默认3个]
    void getHttpConnectionCacheMaxCountPreKeyCase();
    //限制Http连接管理器中缓存的Http连接数量，超过上限时将尝试开始清理缓存中超时或已关闭的连接，如仍不足则放弃缓存[受_max_count_inpool约束，默认10个]
    void getHttpConnectionCacheMaxCountCase();
#else
    //简单的多线程测试
    void multithreadingCase();
#endif



private:
#ifdef MP_JUST_MULTITHREAD
    mpHttpConnectionManageThread hcmt;
#endif
    std::string _schema;
    std::string _host;
    std::string _port;

    std::string _schema1;
    std::string _host1;
    std::string _port1;

    std::string _schema2;
    std::string _host2;
    std::string _port2;

    std::string _schema3;
    std::string _host3;
    std::string _port3;
};

#endif // MPHTTPCONNECTIONMANAGETESTS_H

